package com.example.demo1;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "StudentDemo")
public class StudentDemo extends HelloServlet{

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String studentName=req.getParameter("studentName");
        String age=req.getParameter("age");
        String phoneNumber = req.getParameter("phoneNumber");
        Student student =new Student();
        student.setStudentName(studentName);
        student.setAge(age);
        student.setPhoneNumber(phoneNumber);
        student.show();
        PrintWriter out=resp.getWriter();
        out.println("username="+studentName+","+"password="+age+","+"PhoneNumber="+phoneNumber);
    }

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {

    }
}
